package dancrawler.client.gamecmd;

import dancrawler.common.Misc;
import dancrawler.client.Client;
import dancrawler.proto.cmd.CmdHandler;
import dancrawler.client.GameObject;
import dancrawler.server.netMsg;

/**
 *
 */
public class CmdRemoveObj extends CmdHandler{
    private Client client;
    protected int[] args = new int[]{2};
    public CmdRemoveObj(Client client)
    {
        this.client = client;
    }

    @Override
    public void handleCmd(netMsg msg) {
        GameObject go = client.getObjectRegister().getGameObject(Misc.bytesToShort(msg.getArgs()[0]));
        if(go == null)
        {
            System.out.println("NUOBJ " + Misc.bytesToShort(msg.getArgs()[0]));
        }
        int x = go.getX();
        int y = go.getY();
        client.getWorld().getTile(x, y).remove(go);
        client.getObjectRegister().removeGameObject(go);
    }



    @Override
    public int getId() {
        return 10;
    }

  
    @Override
    public CmdHandler getHandler() {
        return this;
    }

}
